#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

class Solution {
public:
    int findContentChildren(vector<int>& g, vector<int>& s)
    {
        sort(g.begin(), g.end());
        sort(s.begin(), s.end());

        int ans = 0;
        int m = g.size();
        int n = s.size();
        if (m == 0 || n == 0 || g[0] > s[n - 1])
        {
            return 0;
        }
        int i = m - 1, j = n - 1;
        while (i >= 0 && j >= 0)
        {
            if (s[j] >= g[i])
            {
                j--;
                i--;
                ans++;
            }
            else
            {
                i--;
            }
        }
        return ans;
    }

    vector<int> numberGame(vector<int>& nums)
    {
        sort(nums.begin(), nums.end());
        int a = 0, b = 0;
        vector<int> arr;
        int i = 0;
        while (i < nums.size())
        {
            a = nums[i];
            i++;
            b = nums[i];
            i++;
            arr.push_back(b);
            arr.push_back(a);
        }
        return arr;
    }
};

int main()
{
    Solution S;
    vector<int> g, s;
    S.findContentChildren(g, s);
    S.numberGame(g);
    return 0;
}